<html>
<head><meta charset="utf-8"><title>Generic over component of another const generic · project-const-generics · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/index.html">project-const-generics</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/Generic.20over.20component.20of.20another.20const.20generic.html">Generic over component of another const generic</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="238514377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/Generic%20over%20component%20of%20another%20const%20generic/near/238514377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/Generic.20over.20component.20of.20another.20const.20generic.html#238514377">(May 12 2021 at 17:39)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(const_generics)]</span><span class="w"></span>
<span class="cp">#![allow(incomplete_features)]</span><span class="w"></span>
<span class="sd">/// this works</span>
<span class="k">struct</span> <span class="nc">P</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">V</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="p">()</span><span class="o">&gt;&gt;</span><span class="p">;</span><span class="w"></span>
<span class="k">trait</span><span class="w"> </span><span class="n">T1</span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">T1</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">P</span><span class="o">&lt;</span><span class="p">{</span><span class="nb">None</span><span class="p">}</span><span class="o">&gt;</span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">T1</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">P</span><span class="o">&lt;</span><span class="p">{</span><span class="nb">Some</span><span class="p">(())}</span><span class="o">&gt;</span><span class="p">{}</span><span class="w"></span>

<span class="sd">/// this doesn't</span>
<span class="sd">/// error[E0207]: the const parameter `R` is not constrained by the impl trait, self type, or predicates</span>
<span class="k">struct</span> <span class="nc">Q</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">V</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="kt">bool</span><span class="o">&gt;&gt;</span><span class="p">;</span><span class="w"></span>
<span class="k">trait</span><span class="w"> </span><span class="n">T2</span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">T2</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Q</span><span class="o">&lt;</span><span class="p">{</span><span class="nb">None</span><span class="p">}</span><span class="o">&gt;</span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">R</span>: <span class="kt">bool</span><span class="o">&gt;</span><span class="w"> </span><span class="n">T2</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Q</span><span class="o">&lt;</span><span class="p">{</span><span class="nb">Some</span><span class="p">(</span><span class="n">R</span><span class="p">)}</span><span class="o">&gt;</span><span class="p">{}</span><span class="w"></span>
</code></pre></div>



<a name="238514526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/Generic%20over%20component%20of%20another%20const%20generic/near/238514526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/Generic.20over.20component.20of.20another.20const.20generic.html#238514526">(May 12 2021 at 17:40)</a>:</h4>
<p>Is the second example intended to be excluded? Or is this a temporary implementation limitation?</p>



<a name="238514676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/Generic%20over%20component%20of%20another%20const%20generic/near/238514676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/Generic.20over.20component.20of.20another.20const.20generic.html#238514676">(May 12 2021 at 17:41)</a>:</h4>
<p><span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="238514728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/Generic%20over%20component%20of%20another%20const%20generic/near/238514728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/Generic.20over.20component.20of.20another.20const.20generic.html#238514728">(May 12 2021 at 17:41)</a>:</h4>
<p>i <em>think</em> this is intended to be excluded</p>



<a name="238514745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/Generic%20over%20component%20of%20another%20const%20generic/near/238514745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/Generic.20over.20component.20of.20another.20const.20generic.html#238514745">(May 12 2021 at 17:41)</a>:</h4>
<p>i might be wrong though,</p>



<a name="238514862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/Generic%20over%20component%20of%20another%20const%20generic/near/238514862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/Generic.20over.20component.20of.20another.20const.20generic.html#238514862">(May 12 2021 at 17:42)</a>:</h4>
<div class="codehilite"><pre><span></span><code>   = note: expressions using a const parameter must map each value to a distinct output value
   = note: proving the result of expressions other than the parameter are unique is not supported
</code></pre></div>



<a name="238514940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/Generic%20over%20component%20of%20another%20const%20generic/near/238514940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/Generic.20over.20component.20of.20another.20const.20generic.html#238514940">(May 12 2021 at 17:42)</a>:</h4>
<p>basically it's that we cant tell that for an arbitrary expression for every given bool we end up with a unique returned value</p>



<a name="238515193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/Generic%20over%20component%20of%20another%20const%20generic/near/238515193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/Generic.20over.20component.20of.20another.20const.20generic.html#238515193">(May 12 2021 at 17:44)</a>:</h4>
<p>Sure, but <code>Some</code> is a simple constructor, and it can easily be proved... from human's side.</p>



<a name="238515827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/Generic%20over%20component%20of%20another%20const%20generic/near/238515827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/Generic.20over.20component.20of.20another.20const.20generic.html#238515827">(May 12 2021 at 17:48)</a>:</h4>
<p>Yea there's probably more things we can make work here :)</p>



<a name="238516022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/Generic%20over%20component%20of%20another%20const%20generic/near/238516022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/Generic.20over.20component.20of.20another.20const.20generic.html#238516022">(May 12 2021 at 17:49)</a>:</h4>
<p>thanks :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>